﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using ReAnimation.Domain;
using ReAnimation.Helpers.Common;
using ReAnimation.MVP.Presenters;
using ReAnimation.MVP.ViewInterfaces;

namespace ReAnimation.MVP.Views
{
    public partial class ChooseMoleculeForm : BaseFormView, IChooseMoleculeView
    {
        private ChooseMoleculePresenter _chooseMoleculePresenter;

        public ChooseMoleculeForm(ChooseMoleculePresenter chooseMoleculePresenter)
        {
            InitializeComponent();
            _chooseMoleculePresenter = chooseMoleculePresenter;
            _chooseMoleculePresenter.View = this;
        }

        public IList<Molecule> Molecules
        {
            set
            {
                MoleculesListBox.DataSource = value;
                MoleculesListBox.Refresh();
            }
        }

        public Molecule CurrentSelectedMolecule
        {
            get { return (Molecule)MoleculesListBox.SelectedItem; }
            set { MoleculesListBox.SelectedItem = value; }
        }

        public event EventHandler MoleculeSelected;

        private void MoleculesListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            
        }

        private void ChooseMoleculeButton_Click(object sender, EventArgs e)
        {
            MoleculeSelected.Throw(sender, e);
        }
    }
}